from django.http import HttpResponse
from django.shortcuts import render, render_to_response
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_protect
from django.utils.translation import ugettext as _
from messages.forms import MessageForm
from digital_scrapbook import settings

from messages import MESSAGES_LOGIN_REDIRECT_FIELD_NAME

@login_required(login_url="login", redirect_field_name=MESSAGES_LOGIN_REDIRECT_FIELD_NAME)
def index(request):
	return render_to_response('messages/index.html', {})

@login_required(login_url="login", redirect_field_name=MESSAGES_LOGIN_REDIRECT_FIELD_NAME)
def detail(request, message_id):
	return HttpResponse("Detalhe de mensagem")

@csrf_protect
@login_required(login_url="login", redirect_field_name=MESSAGES_LOGIN_REDIRECT_FIELD_NAME)
def new(request):
	form = MessageForm(request.POST or None)
	context = {'form': form}
	return render(request, "messages/new.html", context);